// pages/student/course/classList/classList.js
var app = getApp();
import {post} from "../../../../asserts/js/request";
import {student_active} from "../../../../asserts/js/common/barList";
import {initCourseInit, getCourseParam} from "../../../../asserts/js/common/shareFun";

Page({

  /**
   * 页面的初始数据
   */
  data: {
    top: app.globalData.bottom + 'px',
    barList: student_active(0),
    studetInfo:null,
    class_list: [],
    className: "",
    danceKind: [],
    courseLevel: [],
    courseNature: [],
    courseKind: [],
    teacherHead: "",
    teacherName: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let _this= this;
    console.log(app.globalData.studentInfo);

    post("/student/queryClassList.do",{
      studentId: app.globalData.studentInfo.studentId
    }).then(data =>{
      _this.setData({
        class_list: data.classList
      })
    })

    this.setData({
      studentInfo: app.globalData.studentInfo
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  showCourseList: function(e){
    console.log(e.currentTarget.dataset.item)
    wx.navigateTo({
      url: '/pages/student/course/courseList/course?'
      +"classId="+ e.currentTarget.dataset.item.classId
      ,
    })
  },
  showCourseProcess:function(e){
    wx.setStorage({
      key: 'choosenStudent',
      data: {
        studentId: app.globalData.studentInfo.studentId,
        studentName: app.globalData.studentInfo.studentName,
        avatarUrl: app.globalData.studentInfo.avatarUrl
      }
    });
    wx.navigateTo({
      url: '/pages/student/course/teacherStuCourse/teacherStuCourse?classId=' 
        + e.currentTarget.dataset.item.classId +
        '&studentId=' + app.globalData.studentInfo.studentId +
        '&studentName=' + app.globalData.studentInfo.studentName +
        '&className=' + e.currentTarget.dataset.item.className
    });
  },
  back: function() {
    wx.navigateBack({
      delta: 0,
    })
  }
})